Replacing Geometric Points
TheGXSetPoint
,GXSetLine
,GXSetCurve
,GXSetRectangle
,GXSetPolygons
, andGXSetPaths
functions allow you to replace the geometry of an existing shape. The limitation of these functions is that you must replace the entire geometry at once.QuickDraw GX provides other, more sophisticated, mechanisms for editing shape geometries. The
GXSetShapePoints
function, which is illustrated in this section, allows you to replace individual geometric points within a shape's geometry. TheGXSetPolygonParts
,GXSetPathParts
, andGXSetShapeParts
functions, which are discussed in the next three sections, provide even more ways to edit the geometries of shapes.The sample function in Listing 2-26 creates a path shape and uses the
GXSetShapePoints
function to replace two of the path's geometric points.Listing 2-26 Replacing geometric points
void ReplaceTopTwoControlPoints(void) { gxShape aPathShape; static long twoCurveGeometry[] = {1, /* number of contours */ 6, /* number of points */ 0x48000000,/* 0100 1000 */ ff(100), ff(150), /* on */ ff(50), ff(100), /* off */ ff(100), ff(50), /* on */ ff(200), ff(50), /* on */ ff(250), ff(100), /* off */ ff(200), ff(150)}; /* on */ static gxPoint newTopGeometry[] = {ff(140), ff(50), ff(160), ff(50)}; aPathShape = GXNewPaths((gxPaths *) twoCurveGeometry); GXSetShapeFill(aPathShape, gxOpenFrameFill); GXSetShapePoints(aPathShape, 3, 2, newTopGeometry); GXDrawShape(aPathShape); GXDisposeShape(aPathShape); }TheGXSetShapePoints
function takes four parameters:
Therefore, the line of code from the sample function in Listing 2-26
- a reference to the shape to edit
- the index of the first geometric point to be replaced
- the number of geometric points to replace
- an array containing the new geometric points
GXSetShapePoints(aPathsShape, 3, 2, newTopGeometry);replaces the third and fourth geometric point from the original path shape with the two geometric points in thenewTopGeometry
array.Figure 2-50 shows the path shape before the geometric points are replaced.
Figure 2-50 A path shape with a flat top
Figure 2-51 shows the path shape after the geometric points are replaced.
Figure 2-51 A path shape with geometric points replaced
For more information about the
GXSetShapePoints
function, see page 2-142.The next three sections give examples of functions that allow you even more control in editing the geometric points of a shape's geometry.
Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help